package com.train.webadmin.app.model;

import com.baomidou.mybatisplus.annotation.*;
import com.train.common.core.util.MyCommonUtil;
import com.train.common.core.annotation.*;
import lombok.Data;

import java.util.Date;

/**
 * 学生签到实体对象。
 *
 * @author xulei
 * @date 2025-03-07
 */
@Data
@TableName(value = "student_sign_in")
public class StudentSignIn {

    /**
     * id。
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 老师id。
     */
    @TableField(value = "teacher_id")
    private Long teacherId;

    /**
     * 班级Id。
     */
    @TableField(value = "class_id")
    private Long classId;

    /**
     * 班级code。
     */
    @TableField(value = "class_code")
    private String classCode;

    /**
     * 学生id。
     */
    @TableField(value = "student_id")
    private Long studentId;

    /**
     * 课程id。
     */
    @TableField(value = "course_id")
    private Long courseId;

    /**
     * 签到时间。
     */
    @TableField(value = "sign_in_time")
    private Date signInTime;

    /**
     * 签到地址。
     */
    @TableField(value = "sign_in_address")
    private String signInAddress;

    /**
     * 修改时间。
     */
    @TableField(value = "update_time")
    private Date updateTime;

    /**
     * 修改用户id。
     */
    @TableField(value = "update_user_id")
    private Long updateUserId;

    /**
     * 创建时间。
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 创建人。
     */
    @TableField(value = "create_user_id")
    private Long createUserId;

    /**
     * signInTime 范围过滤起始值(>=)。
     */
    @TableField(exist = false)
    private String signInTimeStart;

    /**
     * signInTime 范围过滤结束值(<=)。
     */
    @TableField(exist = false)
    private String signInTimeEnd;

    /**
     * class_code LIKE搜索字符串。
     */
    @TableField(exist = false)
    private String searchString;

    public void setSearchString(String searchString) {
        this.searchString = MyCommonUtil.replaceSqlWildcard(searchString);
    }

    @RelationOneToOne(
            masterIdField = "teacherId",
            slaveModelClass = TeacherInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private TeacherInfo teacherInfo;

    @RelationOneToOne(
            masterIdField = "classId",
            slaveModelClass = ClassInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private ClassInfo classInfo;

    @RelationOneToOne(
            masterIdField = "studentId",
            slaveModelClass = StudentInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private StudentInfo studentInfo;

    @RelationOneToOne(
            masterIdField = "courseId",
            slaveModelClass = CourseInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private CourseInfo courseInfo;
}
